home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / tip / counters.tip < prev    next >
Text File  |  1993-09-15  |  3KB  |  88 lines

  1. % This macro source file is from the four volume series
  2. % "TeX in Practice" by Stephan von Bechtolsheim, published
  3. % 1993 by Springer-Verlag, New York.
  4. % Copyright 1993 Stephan von Bechtolsheim.
  5. % No warranty or liability is assumed.
  6. % This macro may be copied freely if no fees other than
  7. % media cost or shipping charges are charged and as long
  8. % as this copyright and the following source code itself
  9. % is not changed. Please see the series for further information.
  10. %
  11. % Version: 1.0
  12. % Date: May 1, 1993
  13. %
  14. %
  15. % This source code is documented in 3.4.2, p. I-71.
  16. % Original source in file "reg1.TEX", starting line 2216.
  17. \wlog{L: "counters.tip" ["reg1.TEX," l. 2216, p. I-71]}%
  18. % This file DOES belong to format "texip."
  19. \InputD{newoutfr.tip}
  20. \InputD{printco.tip}
  21. \InputD{namedef.tip}
  22. \catcode`\@ = 11
  23. \def\NewCounter #1#2#3#4{%
  24.     \wlog{\string\NewCounter: allocating new counter "#1."}%
  25.     \if\NameDefinedConditional{@C-#1}%
  26.         \errmessage{\string\NewCounter: counter "#1" was
  27.             allocated previously.}% 
  28.     \fi
  29.     \expandafter\newcountOF\csname @C-#1\endcsname
  30.     \ReassignCounter{#1}{#2}{#3}{#4}%
  31.     \NameDef{@ResetC-#1}{}% 
  32. }
  33. \def\ReassignCounter #1#2#3#4{%
  34.     \if\NameDefinedConditional{@C-#1}%
  35.     \else
  36.         \errmessage{\string\ReassignCounter: counter "#1"
  37.             not defined before.}% 
  38.     \fi
  39.     \NameDef{@TheC-#1}{% 
  40.         \expandafter\expandafter\expandafter#2% 
  41.         \expandafter{\csname @C-#1\endcsname}% 
  42.     }% 
  43.     \NameDef{@TheArabicC-#1}{% 
  44.         \expandafter\the\csname @C-#1\endcsname 
  45.     }% 
  46.     \NameDef{@PriC-#1}{#3}% 
  47.     \NameDef{@RefC-#1}{#4}%
  48. }
  49. \def\TheCounter #1{% 
  50.     \NameUse{@TheC-#1}% 
  51. }
  52. \def\TheArabicCounter #1{% 
  53.     \NameUse{@TheArabicC-#1}% 
  54. }
  55. \def\PrintCounter #1{% 
  56.     \NameUse{@PriC-#1}% 
  57. }
  58. \def\RefCounter #1{% 
  59.     \NameUse{@RefC-#1}% 
  60. }
  61. \let\RefCounterTwo = \RefCounter
  62. \def\CounterToRegister #1#2{%
  63.     #1 = \csname @C-#2\endcsname\relax
  64. }
  65. \def\AddCounterToResetList #1#2{% 
  66.     {% 
  67.         \def\@ResetCounter{\noexpand\@ResetCounter}% 
  68.         \expandafter\xdef\csname @ResetC-#2\endcsname{% 
  69.             \csname @ResetC-#2\endcsname\@ResetCounter{#1}% 
  70.         }% 
  71.     }% 
  72. }
  73. \def\StepCounter #1{% 
  74.     \global\expandafter\advance\csname @C-#1\endcsname by 1
  75.     \NameUse{@ResetC-#1}% 
  76. }
  77. \def\SetCounter #1#2{% 
  78.     \global\expandafter\csname @C-#1\endcsname = #2\relax
  79. }
  80. \def\AssignCounterToReg #1#2{%
  81.     #2 = \expandafter\csname @C-#1\endcsname
  82.     \relax
  83. }
  84. \def\@ResetCounter #1{% 
  85.     \global\csname @C-#1\endcsname = 0
  86. }
  87. \catcode`\@ = 12
  88.